/**
 * 
 */
package com.photoinfo.app.service;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * @author robh
 *
 */
public class SerializationServiceImpl implements SerializationService {
	
	
	public void serialize(String path, Object object) throws FileNotFoundException, IOException {
		
		FileOutputStream fos = new FileOutputStream(path);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        
        oos.writeObject(object);

        oos.close();
	}
	
	public Object deSerialize(String path) throws FileNotFoundException, IOException, ClassNotFoundException {
		Object o;
		FileInputStream fos = new FileInputStream(path);
        ObjectInputStream oos = new ObjectInputStream(fos);
        
        o = oos.readObject();
        oos.close();
        
        return o;
	}
}
